package com.example.teamilkmall.controller;

import com.example.teamilkmall.controller.vo.ResultVO;
import com.example.teamilkmall.entity.FacadeInfo;
import com.example.teamilkmall.service.FacadeInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/facadeInfo")
public class FacadeInfoController extends BaseController{

    private FacadeInfoService facadeInfoService;

    public FacadeInfoController(FacadeInfoService facadeInfoService) {
        this.facadeInfoService = facadeInfoService;
    }

    @GetMapping("/listFacadeInfo")
    public ResultVO<PageInfo<FacadeInfo>> listAdmin(Integer limit, Integer page, String name){
        PageInfo<FacadeInfo> pageInfo = facadeInfoService.listFacadeInfo(limit, page, name);
        return success(pageInfo);
    }

    @PostMapping("/updateFacadeInfo")
    public ResultVO updateAdmin(FacadeInfo facadeInfo){
        facadeInfoService.updateFacadeInfo(facadeInfo);
        return success();
    }

    @PostMapping("/deloneFacadeInfo")
    public ResultVO deloneAdmin(Integer id){
        facadeInfoService.deloneFacadeInfo(id);
        return success();
    }

    @PostMapping("/addFacadeInfo")
    public ResultVO addAdmin(FacadeInfo facadeInfo){
        facadeInfoService.addFacadeInfo(facadeInfo);
        return success();
    }

    @PostMapping("/listFacadeInfoAll")
    public ResultVO<List<FacadeInfo>> getAdminList(){
        return success(facadeInfoService.listFacadeInfoAll());
    }
}
